let brand = "brand";
let userMenu = "menu"
const get_localbrand = () => {
    let brandRoutes = JSON.parse(window.localStorage.getItem(brand));
    if (brandRoutes) {
        return brandRoutes
    } else {
        return false
    }
}
const set_localbrand = (routes) => {
    window.localStorage.setItem(brand, JSON.stringify(routes));
}

const remove_localbrand = (route) => {
    window.localStorage.removeItem(brand)
}

// 设置用户本地存储菜单
const getMenu = () => {
    let dymicRoutes = JSON.parse(window.localStorage.getItem(userMenu));
    if (dymicRoutes) {
        dymicRoutes.forEach(route => {
            if (!route["component"]) {
                route.component = () => import("@/layout")
                route.children.forEach(rout => { rout.component = () => import(`@/views${rout.meta.url}`) })
            }
        })
        return dymicRoutes
    }
}
const setMenu = (menu) => {
    window.localStorage.setItem(userMenu, JSON.stringify(menu));
}

const removeMenu = () => {
    window.localStorage.removeItem(userMenu)
}

export {
    get_localbrand,
    set_localbrand,
    remove_localbrand,
    getMenu,
    setMenu,
    removeMenu
}

